SI Units
Conversions between SI quantities (speed, opening) and the command/status blocks' 0..255 register values, scaled by a DeviceProfile.
Every mapping here is linear and the gripper is not: the manual gives the 2F speed scale as approximate, and a register value is a setpoint, not a measurement.
Speed maps [minSpeed, maxSpeed] onto register values 0..255, because value 0 is the gripper's minimum, not zero. A value below minSpeed floors at register 0 and a value above maxSpeed saturates at 255. NaN, infinity and a negative value yield nothing: no benign caller produces them.
Opening maps [minOpening, maxOpening] onto the profile's register band and clamps to those ends rather than rejecting, because position setpoints from interpolating controllers overshoot the ends by a hair and holding the previous command there would be the wrong outcome. Values round to nearest, so inside the band a position read back commands the same value. A closed gripper settles a few steps either side of closedPosition, so a reading there converts to an opening a touch off minOpening; values past the band read as the nearest end.
A profile the arithmetic cannot use (a non-positive position span or register band, or maxSpeed at or below minSpeed) yields nothing.
The opening conversions (openingToRegister, openingFromRegister) are only valid while the gripper stays in parallel-finger mode. In encompassing mode gPO can exceed closedPosition; openingFromRegister has no way to detect that and clamps the reading to the nearest end instead, which does not reflect the real opening.
- Example
-
using Robotiq::profiles::k2F85;namespace units = Robotiq::units;constexpr double kSpeed = 0.150; // m/sconstexpr double kOpening = 0.040; // mconstexpr double kEffort = 0.5; // fraction of maximum forceRobotiq::GripperCommand command = Robotiq::GripperCommand::defaults();command.speed = units::speedToRegister(kSpeed, k2F85).value();command.force = units::effortToRegister(kEffort).value();command.positionRequest = units::openingToRegister(kOpening, k2F85).value();double openingMetres = units::openingFromRegister(gripper.getStatus().position, k2F85).value();
Members
| Classes | |
| struct | DeviceProfile |
|
Gripper model specific profile gathering specifications such as opening range and speed. More... | |
| Functions | |
| std::optional< uint8_t > | registerFromSpan (double value, double minimum, double maximum) |
| std::optional< uint8_t > | speedToRegister (double speed, const DeviceProfile &profile) |
| std::optional< uint8_t > | openingToRegister (double opening, const DeviceProfile &profile) |
| std::optional< double > | openingFromRegister (uint8_t value, const DeviceProfile &profile) |
| std::optional< uint8_t > | effortToRegister (double effort) |
| constexpr double | motorCurrentFromRegister (uint8_t value) |
| Variables | |
| constexpr DeviceProfile | k2F85 {0.020, 0.150, 0.0, 0.085, 3, 230} |
|
The measured profile for the 2F-85. More... | |
Functions
effortToRegister()
|
Effort in [0, 1] -> rFR. 0 is the gripper's minimum force, 1 its maximum; a value above 1 saturates at register 255.
- Parameters
-
effort Requested gripping effort, as a fraction of the gripper's force range.
- Returns
rFR, or std::nullopt if effort is non-finite or negative.
motorCurrentFromRegister()
| inline constexpr |
gCU -> motor current in A.
- Parameters
-
value The raw register value (gCU).
- Returns
The motor current in amperes.
openingFromRegister()
|
gPO -> opening in m.
Valid only while the gripper stays in parallel-finger mode. A gPO reading taken in encompassing mode can exceed profile.closedPosition and is clamped to the nearest end below instead of reflecting the real opening.
- Parameters
-
value The raw register value (gPO). A value outside the profile's register band reads as the nearest end.
profile The device profile to scale against.
- Returns
The opening in metres, or std::nullopt if profile is one the arithmetic can't use (non-positive position span or register band).
openingToRegister()
|
Opening in m -> rPR.
Valid only while the gripper stays in parallel-finger mode: profile.minOpening/maxOpening and the register endpoints are measured in that mode, so a register computed here does not correspond to a real opening once the gripper switches to encompassing mode.
- Parameters
-
opening Target opening, in metres. Clamped to [profile.minOpening, profile.maxOpening] rather than rejected — a value outside that range reads as the nearest end. Values round to the nearest register.
profile The device profile to scale against.
- Returns
rPR, or std::nullopt if opening is non-finite, or profile is one the arithmetic can't use (non-positive position span or register band).
registerFromSpan()
|
Linear map of [minimum, maximum] onto register values 0..255, the rule speedToRegister applies. Public for callers that carry their own scales instead of a DeviceProfile.
- Parameters
-
value The quantity to convert. A value below minimum floors at register 0; a value above maximum saturates at 255.
minimum The value that maps to register 0.
maximum The value that maps to register 255.
- Returns
The mapped register, or std::nullopt if value is non-finite or negative, minimum or maximum is non-finite, or maximum is at or below minimum.
speedToRegister()
|
Speed in m/s -> rSP.
- Parameters
-
speed Requested speed, in m/s. A value below profile.minSpeed floors at register 0; a value above profile.maxSpeed saturates at 255.
profile The device profile to scale against.
- Returns
rSP, or std::nullopt if speed is non-finite or negative, or profile is one the arithmetic can't use (maxSpeed at or below minSpeed).
Variables
k2F85
| constexpr |
The measured profile for the 2F-85.
Assumes that the gripper is in parallel-finger mode.
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.